package cn.restcloud.springboot.config;

import feign.Client;
import feign.Feign;
import feign.codec.Encoder;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.cloud.openfeign.FeignAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import cn.restcloud.framework.client.feign.OkHttpClient;

@Configuration
@ConditionalOnClass({Feign.class})
@ConditionalOnProperty(value = "feign.okhttp.enabled", matchIfMissing = true)
@AutoConfigureBefore(FeignAutoConfiguration.class)
public class OkHttpClientAutoConfiguration {
	//feign配置类
	
    @Bean
    public Client feignClient() {
    	Client client=new OkHttpClient();
        return client;
    }
    
    @Bean
    @Primary
    Encoder feignFormEncoder() {
        return new FeignFormEncoder();
    }
    
}



